package cn.tedu.charging.device.dao.repository;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class StationCacheFactory {
    /**
     * 读取配置文件
     */
    @Value("${station.warm.dataType}")
    private String dataType;

    @Autowired
    @Qualifier("GeoAndString")
    private StationCacheRepository stationCacheGeoAndStringRepository;

    @Autowired
    @Qualifier("GeoAndGeo")
    private StationCacheRepository stationCacheGeoAndGeoRepository;

    @Autowired
    @Qualifier("GeoAndShareHash")
    private StationCacheRepository stationCacheGeoAndShareHashRepository;

    @Autowired
    @Qualifier("GeoAndNoShareHash")
    private StationCacheRepository stationCacheGeoAndNoShareHashRepository;

    public StationCacheRepository getStationCacheRepository(){
        if(dataType.equals("GeoAndString")){//因该写成常量
            return stationCacheGeoAndStringRepository;
        }else if (dataType.equals("GeoAndGeo")){//应该写成常量
            return stationCacheGeoAndGeoRepository;
        }else if("GeoAndShareHash".equals(dataType)){
            return stationCacheGeoAndShareHashRepository;
        }else if("GeoAndNoShareHash".equals(dataType)){
            return stationCacheGeoAndNoShareHashRepository;
        }
        return null;
    }
}
